import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '机构id',
    align: 'center',
    dataIndex: 'hospitalId_dictText',
    customCell: () => {
      return {
        style: {
          wordWrap: 'break-word',
          wordBreak: 'break-all',
          whiteSpace: 'pre-wrap',
        },
      };
    },
  },
  {
    title: '服务一级模块',
    align: 'center',
    dataIndex: 'mode_dictText',
    customCell: () => {
      return {
        style: {
          wordWrap: 'break-word',
          wordBreak: 'break-all',
          whiteSpace: 'pre-wrap',
        },
      };
    },
  },
  {
    title: '底层模块',
    align: 'center',
    dataIndex: 'button_dictText',
    customCell: () => {
      return {
        style: {
          wordWrap: 'break-word',
          wordBreak: 'break-all',
          whiteSpace: 'pre-wrap',
        },
      };
    },
  },
  {
    title: '热门服务模块',
    align: 'center',
    dataIndex: 'service_dictText',
    customCell: () => {
      return {
        style: {
          wordWrap: 'break-word',
          wordBreak: 'break-all',
          whiteSpace: 'pre-wrap',
        },
      };
    },
  },
  {
    title: '服务半径(公里)',
    align: 'center',
    dataIndex: 'radius',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "机构id",
      field: 'hospitalId',
      component: 'JSearchSelect',
      componentProps:{
          dict: "nurse_hospital,name,id",
          placeholder: '请选择机构',
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '机构id',
    field: 'hospitalId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"nurse_hospital,name,id"
     },
  },
  {
    label: '服务一级模块',
    field: 'mode',
    component: 'JCheckbox',
    componentProps:{
        dictCode:"nurse_type"
     },
  },
  {
    label: '底层模块',
    field: 'button',
    component: 'JCheckbox',
    componentProps:{
        dictCode:"button_type"
     },
  },
  {
    label: '热门服务模块',
    field: 'service',
    component: 'JCheckbox',
    componentProps:{
        dictCode:"hotservice_type"
     },
  },
  {
    label: '服务半径(公里)',
    field: 'radius',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入服务半径(公里)',
      min: 0,
      step: 0.1,
      precision: 2,
      style: { width: '100%' },
    },
    rules: [
      {
        pattern: /^\d+(\.\d+)?$/,
        message: '请输入有效的数字（可以是小数）',
      },
    ],
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  hospitalId: {title: '机构id',order: 0,view: 'list', type: 'string',dictTable: "nurse_hospital", dictCode: 'id', dictText: 'name',},
  mode: {title: '服务一级模块',order: 1,view: 'checkbox', type: 'string',dictCode: 'nurse_type',},
  button: {title: '底层模块',order: 2,view: 'checkbox', type: 'string',dictCode: 'button_type',},
  service: {title: '热门服务模块',order: 3,view: 'checkbox', type: 'string',dictCode: 'hotservice_type',},
  radius: {title: '服务半径(公里)',order: 4,view: 'number', type: 'number',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}